
*********************************************************
*** Table 3a *******************************************
********************************************************


*** PREPARE PUMS DATA FOR TABLE 3A ***************************

clear

cd "C:\Users\Craig Garthwaite\Dropbox\Evans and Moore - Crack\"

use pums70_80

gen whitenh=race==1  & hispan==0
gen blacknh=race==2  & hispan==0
gen hispanic=hispan>0
gen inpoverty=poverty<=100

gen blackpoverty=inpoverty==1 & blacknh==1
gen whitepoverty=inpoverty==1 & whitenh==1
gen hispanicpoverty=inpoverty==1 & hispanic==1

keep year whitenh blacknh hispanic inpoverty metaread year perwt blackpoverty whitepoverty hispanicpoverty 
collapse whitenh blacknh hispanic inpoverty blackpoverty whitepoverty hispanicpoverty [aw=perwt], by(metaread year)
reshape wide whitenh blacknh hispanic inpoverty blackpoverty whitepoverty hispanicpoverty, i(metaread) j(year)

rename metaread msafips
sort msafips
merge msafips using final_distance_data
drop _merge
sort msafips
merge msafips using crack_arrives_duration_2
tab _merge


drop if  whitenh1970==.
drop if  whitenh1980==.

gen  white_change=whitenh1980-whitenh1970
gen  black_change=blacknh1980-blacknh1970
gen  hispanic_change=hispanic1980-hispanic1970
gen  poverty_change=inpoverty1980-inpoverty1970

gen perblackpov1980=blackpoverty1980/blacknh1980
gen perblackpov1970=blackpoverty1970/blacknh1970
gen perblackpov_change= perblackpov1980- perblackpov1970
gen perwhitepov1980=whitepoverty1980/whitenh1980
gen perwhitepov1970=whitepoverty1970/whitenh1970
gen perwhitepov_change= perwhitepov1980- perwhitepov1970
gen perhisppov1980=hispanicpoverty1980/hispanic1980
gen perhisppov1970=hispanicpoverty1970/hispanic1970
gen perhisppov_change= perhisppov1980- perhisppov1970


save pums, replace
clear

* Generate Labor Force Figures for People Over Age 18

cd "C:\Users\Craig Garthwaite\Dropbox\Evans and Moore - Crack\"

use pums70_80
keep if age>18

gen whitenh=race==1  & hispan==0
gen blacknh=race==2  & hispan==0
gen hispanic=hispan>0
gen unemp=empstat==2

gen nohs=educ<6
gen hsgrad=educ==6
gen somecoll=educ>6 & educ<10
gen collgrad=educ>=10

gen blacknohs=nohs==1 & blacknh==1
gen whitenohs=nohs==1 & whitenh==1
gen hispanicnohs=nohs==1 & hispanic==1

gen blackunemp=blacknh==1 & unemp==1
gen whiteunemp=whitenh==1 & unemp==1
gen hispanicunemp=hispanic==1 & unemp==1



keep year whitenh blacknh hispanic unemp whiteunemp blackunemp hispanicunemp metaread perwt 

collapse whitenh blacknh hispanic unemp whiteunemp blackunemp hispanicunemp [aw=perwt], by(metaread year)


reshape wide whitenh blacknh hispanic unemp whiteunemp blackunemp hispanicunemp, i(metaread) j(year)

rename metaread msafips

gen perblackunemp1980= blackunemp1980/ blacknh1980
gen perblackunemp1970= blackunemp1970/ blacknh1970

gen perwhiteunemp1980= whiteunemp1980/ whitenh1980
gen perwhiteunemp1970= whiteunemp1970/ whitenh1970

gen perhispanicunemp1980= hispanicunemp1980/ hispanic1980
gen perhispanicunemp1970= hispanicunemp1970/ hispanic1970

gen perblackunemp_change=perblackunemp1980-perblackunemp1970
gen perwhiteunemp_change=perwhiteunemp1980-perwhiteunemp1970
gen perhispanicunemp_change=perhispanicunemp1980-perhispanicunemp1970

gen unempchange=unemp1980-unemp1970


sort msafips
save pumsover18unemp, replace

clear

* Generate Education Figures for People Over Age 25

cd "C:\Users\Craig Garthwaite\Dropbox\Evans and Moore - Crack\"

use pums70_80
keep if age>25

gen whitenh=race==1  & hispan==0
gen blacknh=race==2  & hispan==0
gen hispanic=hispan>0
gen nohs=educ<6
gen hsgrad=educ==6
gen somecoll=educ>6 & educ<10
gen collgrad=educ>=10

gen blacknohs=nohs==1 & blacknh==1
gen whitenohs=nohs==1 & whitenh==1
gen hispanicnohs=nohs==1 & hispanic==1

gen blackhsgrad=hsgrad==1 & blacknh==1
gen whitehsgrad=hsgrad==1 & whitenh==1
gen hispanichsgrad=hsgrad==1 & hispanic==1

gen blacksomecoll=somecoll==1 & blacknh==1
gen whitesomecoll=somecoll==1 & whitenh==1
gen hispanicsomecoll=somecoll==1 & hispanic==1


keep year nohs hsgrad somecoll collgrad blacknohs whitenohs hispanicnohs blackhsgrad whitehsgrad hispanichsgrad blacksomecoll whitesomecoll hispanicsomecoll whitenh blacknh hispanic metaread perwt 
collapse whitenh blacknh hispanic nohs hsgrad somecoll collgrad blacknohs whitenohs hispanicnohs blackhsgrad whitehsgrad hispanichsgrad blacksomecoll whitesomecoll hispanicsomecoll [aw=perwt], by(metaread year)
reshape wide whitenh blacknh hispanic nohs hsgrad somecoll collgrad blacknohs whitenohs hispanicnohs blackhsgrad whitehsgrad hispanichsgrad blacksomecoll whitesomecoll hispanicsomecoll, i(metaread) j(year)

gen perblacknohs1980= blacknohs1980/ blacknh1980
gen perblacknohs1970= blacknohs1970/ blacknh1970

gen perwhitenohs1980= whitenohs1980/ whitenh1980
gen perwhitenohs1970= whitenohs1970/ whitenh1970

gen perhispanicnohs1980= hispanicnohs1980/ hispanic1980
gen perhispanicnohs1970= hispanicnohs1970/ hispanic1970

gen perblacknohs_change_25=perblacknohs1980-perblacknohs1970
gen perwhitenohs_change_25=perwhitenohs1980-perwhitenohs1970
gen perhispanicnohs_change_25=perhispanicnohs1980-perhispanicnohs1970


gen perblackhsgrad1980= blackhsgrad1980/ blacknh1980
gen perblackhsgrad1970= blackhsgrad1970/ blacknh1970

gen perwhitehsgrad1980= whitehsgrad1980/ whitenh1980
gen perwhitehsgrad1970= whitehsgrad1970/ whitenh1970

gen perhispanichsgrad1980= hispanichsgrad1980/ hispanic1980
gen perhispanichsgrad1970= hispanichsgrad1970/ hispanic1970

gen perblackhsgrad_change_25=perblackhsgrad1980-perblackhsgrad1970
gen perwhitehsgrad_change_25=perwhitehsgrad1980-perwhitehsgrad1970
gen perhispanichsgrad_change_25=perhispanichsgrad1980-perhispanichsgrad1970


gen perblacksomecoll1980= blacksomecoll1980/ blacknh1980
gen perblacksomecoll1970= blacksomecoll1970/ blacknh1970

gen perwhitesomecoll1980= whitesomecoll1980/ whitenh1980
gen perwhitesomecoll1970= whitesomecoll1970/ whitenh1970

gen perhispanicsomecoll1980= hispanicsomecoll1980/ hispanic1980
gen perhispanicsomecoll1970= hispanicsomecoll1970/ hispanic1970

gen perblacksomecoll_change_25=perblacksomecoll1980-perblacksomecoll1970
gen perwhitesomecoll_change_25=perwhitesomecoll1980-perwhitesomecoll1970
gen perhispanicsomecoll_change_25=perhispanicsomecoll1980-perhispanicsomecoll1970

rename metaread msafips
sort msafips
save pumsover25educ, replace


use pums
keep if _merge==3
drop _merge
sort msafips
merge msafips using pumsover18unemp
keep if _merge==3
drop _merge
sort msafips
merge msafips using pumsover25educ


gen mindist=min(miami,nyc,losangeles)
gen ln_population=ln(population)


replace whitenh1980=whitenh1980*100
replace blacknh1980=blacknh1980*100
replace perblackpov1980=perblackpov1980*100
replace perblackunemp1980=perblackunemp1980*100 
replace perblacknohs1980=perblacknohs1980*100
replace perblackhsgrad1980=perblackhsgrad1980*100
replace perblacksomecoll1980=perblacksomecoll1980*100
replace mindist=mindist/100


replace white_change=white_change*100
replace black_change=black_change*100
replace perblackpov_change=perblackpov_change*100
replace perblackunemp_change=perblackunemp_change*100
replace perblacknohs_change=perblacknohs_change*100
replace perblackhsgrad_change=perblackhsgrad_change*100
replace perblacksomecoll_change=perblacksomecoll_change*100


stset duration

*Table 3a, Column 1
streg mindist ln_population whitenh1980 blacknh1980 perblackpov1980 perblackunemp1980 perblacknohs1980 perblackhsgrad1980 perblacksomecoll1980, d(weibull) robust 

*Table 3a, Column 2
streg mindist ln_population white_change black_change perblackpov_change perblackunemp_change perblacknohs_change perblackhsgrad_change perblacksomecoll_change, d(weibull) robust 


***************************************************************
*** Table 3b **************************************************
***************************************************************


clear


set more off

cd "C:\Users\Craig Garthwaite\Dropbox\Evans and Moore - Crack\"
use "C:\Users\Craig Garthwaite\Dropbox\Evans and Moore - Crack\es_202_final.dta", clear

log using es_202_results.log, replace

* generate years crack arrives since 1908 variables
gen duration=crackyear-1980
stset duration

replace mindist=mindist/100

* generate logpop1980
gen logpop1980=log(population1980)

* generate employment to population difference 1980 to 1984
gen emppop1980= employment1980/ population1980
gen emppop1984= employment1980/ population1984
gen empdiff= emppop1984- emppop1980

* generate transfers per capita difference 1980 to 1984
gen trans1984= transferreceipts1984 / population1984
gen trans1980= transferreceipts1980 / population1980
gen transdiff= trans1984- trans1980

* genreate difference in average wage per job
gen wagediff= avgwageperjob1984- avgwageperjob1980

streg mindist , d(weibull) robust
streg logpop mindist , d(weibull) robust
streg logpop mindist empdiff transdiff wagediff , d(weibull) robust


log close
